import asyncio
import websockets


async def hello(websocket, path):
    name = await websocket.recv()
    print(f"< {name}")
    greeting = f"Hello {name}!"
    if name == "lili":
        await asyncio.sleep(5)
    else:
        await asyncio.sleep(7)

    await websocket.send(greeting)
    print(f"> {greeting}")


start_server = websockets.serve(hello, "localhost", 8899)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
